package com.hsh.maoduo.controller;

import com.hsh.maoduo.common.Result;
import com.hsh.maoduo.pojo.dto.GoodsDTO;
import com.hsh.maoduo.pojo.vo.GoodsVO;
import com.hsh.maoduo.service.GoodsService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/goods")
public class GoodsController {


    @Resource
    private GoodsService goodsService;

    @GetMapping("/list")
    public List<GoodsDTO> getList(GoodsVO goodsVO) {
        return goodsService.getList(goodsVO);
    }

    @GetMapping("/export")
    public Result export(GoodsVO goodsVO) {
        return goodsService.export(goodsVO);
    }

    @PostMapping("/update")
    public Result update(GoodsVO goodsVO) {
        return goodsService.update(goodsVO);
    }

    @PostMapping("/addOne")
    public Result addOne(GoodsVO goodsVO) {
        return goodsService.addOne(goodsVO);
    }


    @PostMapping("/delete")
    public Result delete(int id) {
        return goodsService.delete(id);
    }
}
